-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
breaking: Switch to ST124 "shorthand notation" syntax in charmcraft.yaml #258
Conversation
Will not be merged until coordinated charmcraft 3 migration (https://chat.canonical.com/canonical/pl/wekd7r4eqtdn7mxhgxgej8zzsr) Depends on #258 |
# TODO: use permalink | ||
warnings.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will address right before merging (when version number for permalink can be predicted)
b18ac77
to
6fbbae5
Compare
cd58963
to
941e2de
Compare
python/cli/data_platform_workflows_cli/craft_tools/charmcraft_platforms.py
Show resolved
Hide resolved
if not isinstance(platforms_, dict): | ||
raise TypeError("Expected type 'dict' for snapcraft.yaml 'platforms'") | ||
for value in platforms_.values(): | ||
if value is not None: | ||
raise ValueError( | ||
"Only shorthand notation supported in snapcraft.yaml 'platforms'. " | ||
"'build-on' and 'build-for' not supported" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't help but think that this is a validation snippet, which could be extracted to a helper function to reduce the cognitive load of parsing this whole collect
function. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think adding a layer of abstraction would improve readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not call replacing a snippet by a function call adding an abstraction layer. Just in case I did not explain myself well enough, this is what I am proposing:
Before
if yaml_data["base"] == "core24":
platforms_ = yaml_data["platforms"]
if not isinstance(platforms_, dict):
raise TypeError("Expected type 'dict' for snapcraft.yaml 'platforms'")
for value in platforms_.values():
if value is not None:
raise ValueError(
"Only shorthand notation supported in snapcraft.yaml 'platforms'. "
"'build-on' and 'build-for' not supported"
)
for platform in platforms_:
# Example `platform`: "amd64"
architecture = craft.Architecture(platform)
platforms.append({"name": platform, "runner": RUNNERS[architecture]})
elif yaml_data["base"] == "core22":
for entry in yaml_data["architectures"]:
# Example: "amd64"
platform = entry["build-on"]
architecture = craft.Architecture(platform)
platforms.append({"name": platform, "runner": RUNNERS[architecture]})
After
if yaml_data["base"] == "core24":
validate_snap_platforms(yaml_data["platforms"]) # However you want to call it
for platform in yaml_data["platforms"]:
# Example `platform`: "amd64"
architecture = craft.Architecture(platform)
platforms.append({"name": platform, "runner": RUNNERS[architecture]})
elif yaml_data["base"] == "core22":
for entry in yaml_data["architectures"]:
# Example: "amd64"
platform = entry["build-on"]
architecture = craft.Architecture(platform)
platforms.append({"name": platform, "runner": RUNNERS[architecture]})
Enables building & releasing multi-base charms with 24.04 in a single charmcraft.yaml and git branch Integration testing is not supported on multiple bases—it is currently only supported on 22.04
Adds support for core24 `platforms` in snapcraft.yaml
cbde588
to
8b74ad4
Compare
This reverts commit 8b74ad4.
Enables building & releasing multi-base charms with 24.04 in a single charmcraft.yaml and git branch
Integration testing is not supported on multiple bases—it is currently only supported on 22.04
Breaking changes
pytest-operator-cache
(which overridesops_test.build_charm
from pytest-operator) now assumes 22.04 baseDeprecation notice
pytest-operator-cache
is deprecated & will be removed in a future release